package com.enhe.gck.fg;

import com.alibaba.fastjson.JSON;
import com.enhe.gck.item.GoodsHWANE16621Item;
import com.kuangkie.carbon.common.RemoveRecordInfo;
import com.kuangkie.carbon.fg.*;
import com.kuangkie.carbon.panel.CarbonPanel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import com.kuangkie.carbon.record.FGRecordComplexus;
import com.kuangkie.carbon.record.ProRecord;
import com.enhe.gck.CarbonBaseConstant; //模型Code
import com.enhe.gck.CarbonEnumKeyValue; //枚举字典信息
import com.enhe.gck.CarbonRelationType; //关系类型Code
import com.enhe.gck.item.GoodsTypeHWANE18600Item; // 模型属性Code

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@Repository(value = "hwane18600366042330866425862")
@Slf4j
public class GoodsTypeHWANE18600BNB implements SecondRoundImproveFuncGroup, RemoveFuncGroup {
	
	@Override
	public void secondImprove(FuncGroupContext context, ProRecord proRecord, FGRecordComplexus recordComplexus,
			ImproveResultFactory improveResultFactory) {
	}

	@Override
	public boolean beforeRemove(FuncGroupContext funcGroupContext, RemoveRecordInfo removeRecordInfo, DeleteMessageFactory defDeleteMessageFactory) {
		Collection<String> list=removeRecordInfo.getRecordCodes();
		for(String id:list){
			Collection<String> zList=CarbonPanel.getRecordDiscover(CarbonBaseConstant.产品类型_cplx).getProRecord(id).getGuestRecordCodes(CarbonRelationType.RR_产品类型_属于产品管理_产品管理);
			log.info("删除子类{}", JSON.toJSON(zList));
			if(zList!=null){
				for(String z:zList){
					CarbonPanel.getFGRecordBuilder(CarbonBaseConstant.产品管理_cpgl,z).putAttribute(GoodsHWANE16621Item.基本属性组_是否删除,true).integrate();
				}
			}
		}
		return true;
	}
}
